module JpMailer::Mobile::Docomo

  def self.match_recipient?(recipient)
    /(.*?)<(.*?)>/ =~ recipient
    !scanner.match($& ? $2 : recipient).nil?
  end

  # 文字コードを指定
  def self.extended(receiver)
    receiver.instance_variable_set(:@charset, 'shift_jis')
    if receiver.enabled_emotion_conversion?
      receiver.instance_variable_set(:@emotion_conversion_table, Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO)
    end
    receiver.extend JpMailer::Mobile::Base
  end

  private
  def self.scanner
    /docomo\.ne\.jp\z/
  end

  public
  def enabled_emotion_conversion?
    defined? Jpmobile::Emoticon ? true : false
  end

end
